<?php
	DEFINE('H1', 'Make Table 3');
	DEFINE('TITLE','Make Table 3');
	require('includes/header.php');
?>	
	<h2><?PHP echo H1 ?></h2>
<?php
if (!isset($_POST['submit'])) {
?>
<form method="post" action="MakeTable3.php">
Rows: <br />
<input type="text" name="rows" /><br />
Cols: <br />
<input type="text" name="cols" />
<p>
<input type="checkbox" name="bors" id="bors" />Border</p>
<p>
<input type="submit" name="submit" value="Submit" />
</p>
</form>

<?php
} else {
?>
<form method="post" action="MakeTable3.php">
Rows: <br />
<input type="text" name="rows" value="<?php if(isset($_POST['rows'])) echo ($_POST['rows']) ?>" /><br />
Cols: <br />
<input type="text" name="cols" value="<?php if(isset($_POST['cols'])) echo ($_POST['cols']) ?>" />
<p>
<input type="checkbox" name="bors" id="bors" <?php if (isset($_POST['bors']))
             {echo (' checked=\"checked\"');} ?>" />Border</p>
<p>
<input type="submit" name="submit" value="Submit" />
</p>
</form>
<?php

$row = $_POST['rows'];
$col = $_POST['cols'];

if (!isset($_POST['bors'])) {
echo"<table border=\"0\">";
} 
else {
$bor = $_POST['bors'];
echo "<table border=\"$bor\">";
}

for ($r=1; $r<=$row; $r++) {
echo "<tr>";
for ($c=1; $c<=$col; $c++)
 { echo "<td>";
 echo "Row $r, Col $c";
 echo "</td>";
 }
 echo "</tr>";
 }
 echo "</table>";
 } 
 ?>

<?php
	require('includes/footer.php');
?>